from django.db import models
from utils.BaseModel import BaseModel
# Create your models here.


# 导航 模型
class NavModel(BaseModel):
    # 编写字段
    navname =models.CharField(max_length=100,verbose_name="导航名称")
    position =models.BooleanField(default=True,verbose_name="导航位置")
    link =models.CharField(max_length=100,verbose_name="导航顺序",blank=True,null=True)
    # 数据库内的表名 方便查找
    class Meta:
        db_table = 'fgnav'
        # verbose_name ="导航"
        # verbose_name_plural = verbose_name

    def __str__(self):
        return self.navname
# banner 模型
class BannerModel(BaseModel):
    name = models.CharField(max_length=100,verbose_name="benner名称")
    imgurl = models.CharField(max_length=200,verbose_name="benner图片")
    link = models.CharField(max_length=200,verbose_name="benner链接",blank=True,null=True)
    class Meta:
        db_table = 'fgbanner'
    def __str__(self):
        return self.name

#分类模型
class CategoryModel(BaseModel):
    catename = models.CharField(max_length=100,verbose_name="分类名称")
    parent = models.ForeignKey("self",on_delete=models.CASCADE,null=True,blank=True,verbose_name="父级分类",related_name="children")
    is_home = models.BooleanField(default=True,verbose_name="是否首页显示")
    is_hot = models.BooleanField(default=False,verbose_name="是否热门")
    is_good = models.BooleanField(default=False,verbose_name="是否精品")
    class Meta:
        db_table = 'fgcategory'

    def __str__(self):
        return self.catename


